var userInfoApp = angular.module("userInfoApp", ["scService"]);
userInfoApp.controller("userInfoController", function($scope, $rootScope, $location, commonService, jsonToStr) {
    //退出登录
    $scope.userInfoPhone = localStorage.getItem("phone").replace(/(\d{3})\d{4}(\d{4})/, '$1****$2');
    var userId = localStorage.getItem("userId");
    var token = localStorage.getItem("token");
    var account = localStorage.getItem("account");
    $scope.outClick = false;
    $scope.logOut = function() {

        $scope.setConfirmEx()

    };
    //确定退出
    $rootScope.sureLogOut = function() {
        $scope.outClick = true;
        $scope.confirmExHide();
        var postData = {
            "source": "124",
            // "userId":userId,
            // "token":token,
            "account": userId,
            "jPushRegId": account,
            "merchantCode": mainConfig.merchantCode
        };
        scCodeService.unlockUser(postData).then(function(data) {
            // alert(JSON.stringify(data));
            if (data.code == "200") {
                localStorage.clear();
                // $location.path("/login/1")
                window.location.href = "http://weixin.mawansan.com/static/wechat-ht/enter.html?state=1"
            } else {
                $scope.outClick = false;
            }
        });
    };
});
userInfoApp.controller("collectController", function($scope, $http, scCodeService, $location, $stateParams, commonService, jsonToStr) {
    $scope.showNav = true;
    $scope.showDele = false;
    $scope.operate = "编辑";
    $scope.collectList;
    //点击“编辑”、“返回”
    $scope.edit = function() {
        $scope.showNav = $scope.showNav == true ? false : true;
        $scope.showDele = $scope.showDele == true ? false : true;
        $scope.operate = $scope.operate == "编辑" ? "返回" : "编辑";
    };
    // 获取收藏列表
    $scope.getCollectList = function() {
        // 模拟数据
        $scope.collectList = [{
            "station": "环球中心充电站",
            "park": "环球中心E2地下停车场"
        }, {
            "station": "环球中心充电站2",
            "park": "环球中心E2地下停车场2"
        }, {
            "station": "环球中心充电站3",
            "park": "环球中心E2地下停车场3"
        }, ]

    };
    //删除一条收藏
    $scope.remove = function(data) {
        var postData = {};
        $scope.toastSet({
            content: '删除成功'
        })
    };
    // 点击导航
    $scope.nav = function() {
        console.log('开始导航');
    };

    // 进入我的收藏执行的方法
    $scope.getCollectList();
});
